package com.inspur.edp.bef.bemanager.validate.operation;

import com.inspur.edp.bef.bizentity.operation.BizOperation;

import static com.inspur.edp.cef.designtime.api.validate.common.CheckUtil.exception;
import static com.inspur.edp.cef.designtime.api.validate.common.CheckUtil.isLegality;

public abstract class BizOperationChecker {
    protected final void opException(String code) {
        if (code == null || code.isEmpty())
            return;
        exception(code);
    }

    //be & deter动作编号
    private void checkActionCode(BizOperation bizOperation) {
        if (bizOperation == null)
            return;
        if (bizOperation.getCode() == null || bizOperation.getCode().isEmpty()) {
            opException("方法编号不允许为空,请修改！");
        }

        if (isLegality(bizOperation.getCode()))
            return;
        opException("方法编号[" + bizOperation.getCode() + "]是java关键字,请修改！");
    }

    public final void checkBizOperation(BizOperation bizOperation) {
        checkActionCode(bizOperation);
        checkBizOperationExtension(bizOperation);
    }

    protected void checkBizOperationExtension(BizOperation bizOperation) {

    }
}
